package com.zhiyu.middle.task;

import com.zhiyu.service.webApi.IScheduleTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDateTime;

@Slf4j
@Component
@Configuration      // 主要用于标记配置类，兼备Component的效果。
@EnableScheduling   // 开启定时任务
public class ScheduleTask {

    @Resource
    private IScheduleTaskService iScheduleTaskService;

    // {秒数} {分钟} {小时} {日期} {月份} {星期} {年份(可为空)}

    // 每天上午8点触发
    @Scheduled(cron = "0 0 8 * * ?")
    private void deviceStockWarningTasks() { // 设备库存预警任务
        log.info("执行[设备库存预警]任务开始时间: " + LocalDateTime.now());
        // 设备库存预警任务
        iScheduleTaskService.deviceStockWarningTasks();
    }

}
